/*
 * ExpansionOP.h
 *
 *  Created on: Jul 5, 2009
 *      Author: mlrus
 */

#ifndef EXPANSION_OP_H__
#define EXPANSION_OP_H__

#include <sstream>
#include <iostream>
#include <ostream>

#include "Board.h"
class ExpansionOP {
	public:
		ExpansionOP() {
		}
		virtual ~ExpansionOP() {
		}
		virtual Axis::Axis getAxis() =0;
		virtual Axis::Axis getDual() =0;
		virtual const int* getExtensionDirections() =0; // + and - offsets
		virtual const int getNumExtensions() =0;
		virtual const string describe() {
			std::ostringstream str;
			str << "ExpansionOP [axis=" << (getAxis() == Axis::HORIZONTAL ? "horizontal" : ((getAxis()
					== Axis::VERTICAL ? "vertical" : "other"))) << "; dual="
					<< (getDual() == Axis::HORIZONTAL ? "horizontal" : ((getDual() == Axis::VERTICAL ? "vertical"
							: "other"))) << "; numExtensions=" << getNumExtensions() << "; directions=[";
			for (const int *direction = getExtensionDirections(); direction < getExtensionDirections()
					+ getNumExtensions(); direction++) {
				str << (*direction) << "; ";
			}
			str << "]";
			return str.str();

		}
};

class HorizontalExpander: public ExpansionOP {
	public:
		HorizontalExpander() {
		}
		virtual ~HorizontalExpander() {
		}
		static const int dirs[2];
		static const int numExtensions;
		static const Axis::Axis axis, dual;
		const int *getExtensionDirections() {
			return dirs;
		}
		const int getNumExtensions() {
			return HorizontalExpander::numExtensions;
		}
		Axis::Axis getAxis() {
			return HorizontalExpander::axis;
		}
		Axis::Axis getDual() {
			return HorizontalExpander::dual;
		}
};

class VerticalExpander: public ExpansionOP {
	public:
		VerticalExpander() {
		}
		virtual ~VerticalExpander() {
		}
		static const int dirs[2];
		static const int numExtensions;
		static const Axis::Axis axis, dual;
		const int *getExtensionDirections() {
			return dirs;
		}
		const int getNumExtensions() {
			return VerticalExpander::numExtensions;
		}
		Axis::Axis getAxis() {
			return VerticalExpander::axis;
		}
		Axis::Axis getDual() {
			return VerticalExpander::dual;
		}
};

#endif /* EXPANSION_OP_H__ */
